 <template>
<view>
	<uni-nav-bar left-icon="left" :statusBar="true"   titleSize="30px" leftText="返回"  rightText="操作"   title="订单详情"  @clickLeft="back"  @clickRight="toeditFn" :fixed="true" backgroundColor="#fd9540" color="#fff"></uni-nav-bar>
	<view class="orderdetails">
		 <view class="details">
			 <view class="list-header">
			 	<view>{{list.orderNo}}</view>
			 	<span>{{list.depositReceivable}}.00元</span>
			 </view>
			 <view  class="list-information">
			 	<view>客户名称:<span>{{list.customerName}}</span></view>
			 	<view>业务员:<span>{{list.salesmanName}}</span></view>
			     <view>订单发起日期:<span>{{list.orderDate}}</span></view>
				 <view  v-if="list.orderStatus==='0'" style="display: flex;"><span style="height:35px;line-height: 35px;">市场部审批:</span> <button v-show="approvalShow" @click="updateFn1" style="background: #13ce66;color:#fff;width: 95px;height: 30px;margin-left: 150px;" size="mini">一键通过</button></view>
				  <view  v-if="list.orderStatus==='8'" style="display: flex;"><span style="height:35px;line-height: 35px;">财务部审批:</span> <button v-show="approvalShow1" @click="updateFn" style="background: #13ce66;color:#fff;width: 95px;height: 30px;margin-left: 150px;" size="mini">一键通过</button></view>
			 </view>
		 </view>
		 <view class="list-name">
			<view>
				 <uni-icons type="calendar" style="font-size: 14px;margin-right: 10px;"></uni-icons>
				{{list.customerName}}
			</view>
			<uni-icons type="right" style="font-size: 14px;"></uni-icons>
		 </view>
		 <uni-row class="demo-uni-row" style='border: solid 1px #eee;'>
			<uni-col :span="12">
				<view style="height:40px;line-height: 40px;border-right: solid 1px #eee;">
					 <uni-icons type="calendar" style="font-size: 14px;margin-right: 10px;"></uni-icons>
					{{list.salesmanName}}
				</view>
			</uni-col>
			<uni-col :span="12">
				<view  style="height:40px;line-height: 40px;">
					 <uni-icons type="calendar" style="font-size: 14px;margin-left: 10px;"></uni-icons>
					 签约
				</view>
			</uni-col>
		</uni-row>
	</view>
	<view class="orderdetails">
			<view style="margin: 10px 0 0 10px; height:40px;line-height: 40px;">
				 <uni-icons type="calendar" style="font-size: 14px;margin-right: 10px;"></uni-icons>
				 金额信息
			</view>
			
				<uni-grid :column="3" :show-border="false" :square="true" >
					<uni-grid-item >
						<view class="grid-item-box">
							<text class="text">{{list.depositReceivable}}.00元</text>
							<text class="text">应收押金/元</text>
						</view>
					</uni-grid-item>
					<uni-grid-item >
						<view class="grid-item-box">
							<text class="text">{{list.receivables}}.00元</text>
							<text class="text">应收款/元</text>
						</view>
					</uni-grid-item>
					<uni-grid-item >
						<view class="grid-item-box">
							<text class="text">{{list.receivedAmount}}.00元</text>
							<text class="text">已收款金额/元</text>
						</view>
					</uni-grid-item>
					<uni-grid-item >
								<view class="grid-item-box">
									<text class="text">{{list.unreceivedAmount}}.00元</text>
							        <text class="text">未收款金额/元</text>
								</view>			
					</uni-grid-item>
					<uni-grid-item >
								<view class="grid-item-box">
									<text class="text">{{list.badDebtAmount}}.00元</text>
							        <text class="text">坏账金额/元</text>
								</view>			
					</uni-grid-item>
		</uni-grid>
	 </view>
	 <!-- tab栏信息 -->
	 <u-tabs class="tabNav orderdetails" :current="index" style='margin-top: 10px;' @change="changeFn" lineWidth="104rpx" lineColor="#fd9540" :activeStyle="{ color:'#fd9540',fontWeight:'bold' }" :list="tabTitle"></u-tabs>
	 		
	 		<u--form labelPosition="left" class='orderdetails' labelWidth="200rpx" ref="form1">
	 			<!-- tab内容 -->
	 			<view class="box" v-if="index*1===0">
	 				<u-cell>
	 					<template #title>
	 						<view class="u-cell-text">基本信息</view>
	 					</template>
	 				</u-cell>
					<u-cell-group>
							<u-cell >
								<view slot="title"  >
									<text class="u-cell-text">发起人</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.sponsorName}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >业务员</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.salesmanName}}</text>
								</view>
							</u-cell>
							<u-cell >
								<view slot="title"  >
									<text class="u-cell-text"  >协同人</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.collaboratorName}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title" >
									<text class="u-cell-text"  >信息提供人</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.informationProviderName}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >发起人所属部门</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.sponsorDeptName}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >订单编号</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.orderNo}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >订单发起日期</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.orderDate}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >业务所属公司</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{businessCompany}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >订单类型</text>
									<text class="u-cell-text" style="margin-left: 10px;" v-if="list.orderType==1">新单</text>
									<text class="u-cell-text" style="margin-left: 10px;" v-if="list.orderType==2">补货</text>
									<text class="u-cell-text" style="margin-left: 10px;" v-if="list.orderType==3">换货</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >客户名称</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.customerName}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >客户类别</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{customerCategory}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title" >
									<text class="u-cell-text"  >客户信息来源</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{customerSource}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title" >
									<text class="u-cell-text"  >客户所属省份</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.customerRegion}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >项目名称</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.projectName}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >项目地区域</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.projectArea}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >项目信息来源</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{projectSource}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title" >
									<text class="u-cell-text"  >租赁形式</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{lease}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >收货地址</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.address}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >发货仓库</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.deliveryWarehouseName}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title" >
									<text class="u-cell-text"  >辅料说明</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.accessoriesInstruction}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >日租金合计</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.totalDailyRent}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >应收押金(元)</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.depositReceivable}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >押金收取方式</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{depositCollectionMethod}}</text>
								</view>
							</u-cell>
						<!-- 	<u-cell   >
								<view slot="title"  class="u-slot-title">
									<text class="u-cell-text"  >押金及价格是否超越权限</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.salesmanName}}</text>
								</view>
							</u-cell> -->
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >情况说明</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.description}}</text>
								</view>
							</u-cell>
							<!-- <u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >附件</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.enclosure}}</text>
								</view>
							</u-cell> -->
							<u-cell   >
								<view slot="title" >
									<text class="u-cell-text"  >业务费情况</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.businessExpenses}}</text>
								</view>
							</u-cell>
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >期望到货日期</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.expectedArrivalDate}}</text>
								</view>
							</u-cell>
							<!-- <u-cell   >
								<view slot="title"  class="u-slot-title">
									<text class="u-cell-text"  >是否需要物流安排车辆</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{list.salesmanName}}</text>
								</view>
							</u-cell> -->
							<u-cell   >
								<view slot="title"  >
									<text class="u-cell-text"  >运输方式</text>
									<text class="u-cell-text" style="margin-left: 10px;">{{shippingType}}</text>
								</view>
							</u-cell>
					</u-cell-group>
	 			</view>
	 			<view class="box" v-if="index*1===1">
					<u-cell>
						<template #title>
							<view class="titcolor">关联产品</view>
						</template>
					</u-cell>
					<view class="productList-box">
						<uni-table border :stripe="true" emptyText="暂无更多数据" >
							<!-- 表头行 -->
							<uni-tr>
								<uni-th align="center" >整机品名</uni-th>
								<uni-th align="center" >型号</uni-th>
								<uni-th align="center" >数量</uni-th>
								<uni-th align="center" >日租金</uni-th>
								<uni-th align="center" >每日租金小计</uni-th>
								<uni-th align="center" >出库数量</uni-th>
								<uni-th align="center" >未出库数量</uni-th>
								<uni-th align="center" >回货数量</uni-th>
								<uni-th align="center" >备注</uni-th>
							</uni-tr>
							<!-- 表格数据行 -->
							<uni-tr v-for="(item) in productList" :key="item.id">
								<uni-td align="center">{{item.productName}}</uni-td>
								<uni-td align="center">{{item.model}}</uni-td>
								<uni-td align="center">{{item.quantity}}</uni-td>
								<uni-td align="center">{{item.dailyRent}}</uni-td>
								<uni-td align="center">{{item.dailyTotalRent}}</uni-td>
								<uni-td align="center">{{item.deliveryQuantity}}</uni-td>
								<uni-td align="center">{{item.undeliveryQuantity}}</uni-td>
								<uni-td align="center">{{item.returnQuantity}}</uni-td>
								<uni-td align="center">{{item.remark}}</uni-td>
							</uni-tr>
						</uni-table>
					</view>
	 				
	 			</view>
	 			<view class="box" v-if="index*1===2">
	 				<u-cell>
	 					<template #title>
	 						<view class="titcolor">维修订单</view>
	 					</template>
	 				</u-cell>
					<view class="productList-box">
						<uni-table border :stripe="true" emptyText="暂无更多数据" >
							<!-- 表头行 -->
							<uni-tr>
								<uni-th align="center"  width="150px">机器编码</uni-th>
								<uni-th align="center"  width="100px">型号</uni-th>
								<uni-th align="center"  width="100px">状态</uni-th>
								<uni-th align="center"  width="100px">操作</uni-th>
								
								
							</uni-tr>
							<!-- 表格数据行 -->
							<uni-tr v-for="(item,index) in machinelist" :key="index">
								<uni-td align="center">{{item.machineNo}}</uni-td>
								<uni-td align="center" >
								<view style="min-width: 100px;">{{item.model}}</view>
								</uni-td>
								<uni-td align="center" >
								<view style="min-width: 100px;" v-if="item.status=='0'">正常</view>
								<view style="min-width: 100px;" v-if="item.status=='1'">维修中</view>
								<view style="min-width: 100px;" v-if="item.status=='2'">使用中</view>
								<view style="min-width: 100px;" v-if="item.status=='3'">未激活</view>
								</uni-td>
								<uni-td align="center">
									<view style="display: flex;">
										<view style="min-width:50px;color:#3c9cff;" @click="repairBtn(item)">报修</view>
										<view style="min-width:50px;color:#3c9cff;" @click="toInfo(item.machineNo,list.orderNo)">详情</view>
									</view>
								</uni-td>
								
							</uni-tr>
						</uni-table>
					</view>
	 			</view>
	 			<view class="box" v-if="index*1===3">
	 				<u-cell>
	 					<template #title>
	 						<view class="titcolor">项目支出</view>
							<view class="addBtn" @click="addBtn">+新增</view>
	 					</template>
	 				</u-cell>
					<view class="productList-box">
					<uni-table border :stripe="true" emptyText="暂无更多数据" >
						<!-- 表头行 -->
						<uni-tr>
							<uni-th align="center" width="100px">项目</uni-th>
							<uni-th align="center"  width="100px">金额</uni-th>
							<uni-th align="center"  width="100px">操作</uni-th>
							
						</uni-tr>
						<!-- 表格数据行 -->
						<uni-tr v-for="(item,index) in moneyList" :key="index">
							<uni-td align="center"  >{{item.projectName}}</uni-td>
							<uni-td align="center" >{{item.projectCost}}	</uni-td>
							<uni-td align="center" >
								<view style="display: flex;margin-left: 40px;">
									<view style="min-width:25px;color:#3c9cff;margin-right: 5px;" @click="addBtn(item)">修改</view>
									<view style="min-width:25px;color:#3c9cff;" @click="delBtn(item)">删除</view>
								</view>
							</uni-td>
							
						</uni-tr>
					</uni-table>
					</view>
	 			</view>
				<view class="box" v-if="index*1===4">
					<u-cell>
						<template #title>
							<view class="titcolor">审批记录</view>
						</template>
					</u-cell>
					<view class="productList-box">
						<uni-table border :stripe="true" emptyText="暂无更多数据" >
							<!-- 表头行 -->
							<uni-tr>
								<uni-th align="center" >序号</uni-th>
								<uni-th align="center" >订单编号</uni-th>
								<uni-th align="center" >市场部审批人</uni-th>
								<uni-th align="center" >审批时间</uni-th>
								<uni-th align="center" >财务部审批人</uni-th>
								<uni-th align="center" >审批时间</uni-th>
							</uni-tr>
							 
							<uni-tr v-for="(item,index) in ApprovalList" :key="item.id">
								<uni-td align="center">{{index}}</uni-td>
								<uni-td align="center">{{item.orderNo}}</uni-td>
								<uni-td align="center">{{item.marketingUserName}}</uni-td>
								<uni-td align="center">{{item.createTime}}</uni-td>
								<uni-td align="center">{{item.financeUserName}}</uni-td>
								<uni-td align="center">{{item.updateTime}}</uni-td>
								 
							</uni-tr>
						</uni-table>
					</view>
				</view>
				<view class="box" v-if="index*1===5">
					<u-cell>
						<template #title>
							<view class="titcolor">电子合同</view>
						</template>
					</u-cell>
					<view class="agreement" >
						<iframe  style="width: 100%; height:500px" :src="`http://101.132.141.5:8081${list.agreement}`" frameborder="0"></iframe>
					</view>
				</view>
				<view class="box" v-if="index*1===6">
					<u-cell>
						<template #title>
							<view class="titcolor">转账凭证</view>
						</template>
					</u-cell>
					<view class="agreement"  @click="photoFn" >
						<a :href="`http://101.132.141.5:8081${list.enclosure}`">
													<u--image :showLoading="true" :src="`http://101.132.141.5:8081${list.enclosure}`"  width="80px" height="80px" ></u--image>
						</a>
					</view>
				</view>
				
	 		</u--form>
			<!-- 项目支出弹框 -->
			<u-popup :closeable="true"  :show="show" mode="center">
				<view class="pop-box">
					<view style="display:flex;margin-bottom: 10px;">
						<view class="title">费用名称</view>
						<u--input placeholder="请输入费用名称" v-model="formData.projectName"  border="surround"></u--input>
					</view>
					<view style="display:flex;">
						<view class="title">金额</view>
						<u--input placeholder="请输入金额" v-model="formData.projectCost"  border="surround"></u--input>
					</view>
					<view class="button">
							<u-button customStyle="width:30px;margin-right:5px;" @click="show=false" size="small" text="取消"></u-button>
							<u-button customStyle="width:30px" type="primary" @click="addMoneyBtn" size="small" text="确定"></u-button>
					</view>
				</view>
			    
			</u-popup>
			<u-modal showConfirmButton showCancelButton @confirm="BtnModel" @cancel="BtnShow=false" width="250px" :show="BtnShow" title="提示" >
				<view class="slot-content">
					<rich-text nodes="是否确认审批通过?"></rich-text>
				</view>
			</u-modal>
			<u-modal showConfirmButton showCancelButton @confirm="BtnModel1" @cancel="BtnShow1=false" width="250px" :show="BtnShow1" title="提示" >
				<view class="slot-content">
					<rich-text nodes="是否确认审批通过?"></rich-text>
				</view>
			</u-modal>
	 	</view>
</template>

<script>
	import {getLoginUser} from '@/api/system/user.js'
	import {getDicts} from '@/api/dictionary/index.js'
	import {getOrder,getMachineList,getMachineList2,updateOrderStatus,updateOrderStatus1,} from '@/api/order/order.js'
	import {getProjectExpendListApi,addProjectExpendApi,editProjectExpendApi,delProjectExpendApi,getProjectExpendApiInfoApi} from '@/api/reported.js'
	import{getApprovalInfo,getApprovalList,editApprovalInfo,addApproval} from '@/api/approval.js'
	export default{
		data(){
		return{
			ApprovalList:[],
			BtnShow:false,
			BtnShow1:false,
			user:{},
			userId:'',
				index:0,
				show:false,//控制项目支出
				tabTitle: [{name: '基本信息'}, 
				{name: '关联产品',},
				{name: '维修订单',}, 
				{name: '项目支出'},
				{name: '审批记录'},
				{name:'电子合同'},
				{name:'转账凭证'}
				],
				id:0,
				list:{},//订单详情数据
				productList:[],//关联产品
				machinelist:[],//订单关联的机器
				formData:{
					projectName:'',
					projectCost:''
				},
				moneyList:[],
				customerOption:[],//客户类型
				customerCategory:'',//客户类型显示
				businessCompanyOption:[],//业务所属公司
				businessCompany:'',
				customerSourceOption:[],
				customerSource:'',
				projectSourceOption:[],//
				projectSource:'',
				depositCollectionMethodOption:[],//押金收取方式
				depositCollectionMethod:'',
				shippingTypeOption:[],
				shippingType:'',
				leaseOPtion:[],
				lease:'',
				 permissions:[],
				 approvalShow:false,
				 approvalShow1:false
				
			}
		},
		onLoad(e){
			// console.log(e);
			this.id=e.id
			this.getPay()
			this.getShippingType()
			this.getcustomerSource()
			this.getCustomertype()
			this.getBusinessCompany()
			this.getProjectSource()
			this.getLease()
			this.initData()
			this.getuser()
			this.permissions=this.$store.getters.permissions
			
		},
	
		methods:{
			photoFn(){
				console.log('11');
				uni.navigateTo({
					url:`http://101.132.141.5:8081${this.list.enclosure}`
				})
			},
			// 市场部审批
			updateFn1(val){
				this.BtnShow=true
			},
			async BtnModel(){
				this.BtnShow=false
				let ApprovalFrom={orderId: this.list.id,orderNo:this.list.orderNo,marketingUserId:this.user.userId,marketingUserName:this.user.username,}
				console.log(ApprovalFrom,11);
				await addApproval(ApprovalFrom)
			    await updateOrderStatus1({id:this.list.id})
				await this.initData()
			},
			// 财务部审批
			updateFn(){
				console.log('11');
				this.BtnShow1=true
			},
			async BtnModel1(){
				this.BtnShow1=false
				let res=await getApprovalList({orderId:this.list.id})
				await editApprovalInfo({id:res.rows[0].id,orderId: res.rows[0].orderId,orderNo:res.rows[0].orderNo,marketingUserId:res.rows[0].marketingUserId,marketingUserName: res.rows[0].marketingUserName,financeUserId:this.user.userId,financeUserName:this.user.username})
			   await updateOrderStatus({id:this.list.id})
			   await this.initData()
			},
			
			//获取登录用户
			async getuser(){
				// getLoginUser().then(response=>{
				// 	this.user=response.user
				// 	this.userId=response.userId
				// 	console.log(this.user.userId);
				// })
				let res=await getLoginUser()
				this.user=res.user
				this.userId=res.user.userId
				await this.initData()
				await this.approval()
				
			},
			// 权限判断
			approval(){
				console.log('111');
				console.log(this.userId);
				console.log(this.list);
				// 市场部审批按钮
				if(this.permissions.includes('*:*:*') ||this.permissions.includes('module:order:updateStatus1')){
						   if(this.userId==117){
							    // this.approvalShow=true
							   if(this.list.purview==='2'){
								  
								   this.approvalShow=true
							   }
						   }
						   if(this.userId==128){
							      if(this.list.purview==='1'){
								   this.approvalShow=true
							   }
						   }
						   if(this.userId==1){
							   this.approvalShow=true
						   }
				}
				// 财务部审批
				if(this.permissions.includes('*:*:*') ||this.permissions.includes('module:order:updateStatus')){
				     this.approvalShow1=true
				}
				
			},
		async initData(){
			const res=  await	getOrder(this.id)
			console.log(res);
			this.list=res.data
			this.customerCategory=this.getValue(this.customerOption,res.data.customerCategory)
			this.businessCompany=this.getValue(this.businessCompanyOption,res.data.businessCompany)
			this.customerSource=this.getValue(this.customerSourceOption,res.data.customerSource)
			this.projectSource=this.getValue(this.projectSourceOption,res.data.projectSource)
			this.shippingType=this.getValue(this.shippingTypeOption,res.data.shippingType)
			this.depositCollectionMethod=this.getValue(this.depositCollectionMethodOption,res.data.depositCollectionMethod)
			this.lease=this.getValue(this.leaseOPtion,res.data.lease)
			this.productList=res.data.productList
			},
			// 客户类别
			getCustomertype(){
				getDicts('biz_category').then(response=>{
					this.customerOption=response.data
				})
			},
			// 业务所属公司
			getBusinessCompany(){
				getDicts('biz_business_company').then(response=>{
					this.businessCompanyOption=response.data
				})
			},
			// 客户来源
			getcustomerSource(){
				getDicts('biz_source').then(response=>{
					this.customerSourceOption=response.data
				})
			},
			// 项目信息
			getProjectSource(){
				getDicts('biz_project_source').then(response=>{
					this.projectSourceOption=response.data
				})
			},
			//  
			getPay(){
				getDicts('pay_ment').then(response=>{
					this.depositCollectionMethodOption=response.data
				})
			},
			getShippingType(){
				getDicts('biz_shipping_type').then(response=>{
					this.shippingTypeOption=response.data
				})
			},
			getLease(){
				getDicts('biz_lease').then(response=>{
					this.leaseOPtion=response.data
					console.log(this.leaseOPtion);
				})
			},
			getValue(arr,item){
				for(var i=0;i<arr.length;i++){
					if(item == arr[i].dictValue){
						return arr[i].dictLabel
					}
				}
			},
			// 机器维修 获取机器列表
		async  getMachine(){
			const res=await getMachineList2({
				orderId:this.id
			})
			// console.log(res);
			this.machinelist=res.rows
			// console.log(this.machinelist);
			},
			// 获取项目支出列表
			async openProjectList(){
			const res=await getProjectExpendListApi(this.formData.projectName)
			// console.log(res);
			this.moneyList=res.rows
			},
			async changeFn(e){
				console.log(e);
				if(e.index==0){
					this.index=0
				}
				if(e.index==1){
					this.index=1
				}
				if(e.index==2){
					this.index=2
					this.getMachine()
				}
				if(e.index==3){
					this.index=3
					this.formData.projectName=this.list.projectName
					this.openProjectList()
				}
				if(e.index==4){
					this.index=4
					let res=await getApprovalList({orderNo:this.list.orderNo})
					this.ApprovalList=res.rows
				}
				if(e.index==5){
					this.index=5
					
				}
				if(e.index==6){
					this.index=6
				}
				
			},
			//项目支出添加按钮
			addBtn(e){
				// console.log(e);
				if(e.id){
					this.formData=e
				}else{
					// 添加
					this.formData.projectName=this.list.projectName
				}
				this.show=true
				
			},
			async addMoneyBtn(){
				// console.log(val);
				if(this.formData.id){
					// 修改
					await editProjectExpendApi(this.formData)
					this.openProjectList()
					this.show=false
				}else{
					// 添加
					await addProjectExpendApi(this.formData)
					this.openProjectList()
					this.show=false
				}
				
			},
			// 删除
			async delBtn(val){
			  await	delProjectExpendApi(val.id)
			  this.openProjectList()
			},
			// 点击报修按钮 跳转
			repairBtn(item){
				console.log(item);
				console.log(this.list);
				item.orderNo=this.list.orderNo
				item.orderId=this.list.id
				uni.navigateTo({
					url:'/pages/repair/addRepair/index?item='+JSON.stringify(item)
				})
			},
			back(){
				uni.navigateBack({delta:1})
			},
			toeditFn(){
				uni.navigateTo({
					url:'/pages/order2/addOrder2/addOrder2?orderInfo='+JSON.stringify(this.list)
				})
			},
			toInfo(val,item){
				let result=[val,item].join(',')
				uni.navigateTo({
					url:'/pages/repair/index?info='+JSON.stringify(result)
				})
			}
			
			
			
		}
	}
</script>

<style lang="scss" scoped>
	.box{
		background-color: #fff;
	}
	.orderdetails{
		background-color: #fff;
		.details{
			padding: 10px;
			border-bottom: solid 1px #eee;
		}
		.u-slot-title{
			display: flex;
			justify-content: space-between;
			
		}
	}
	.list-header{
		display: flex;
		justify-content: space-between;
		span{
			color: #ff7c35;
		}
		
	}
	.list-information{
		font-size: 13px;
		margin-right: 20px;
		view{
			padding: 3px 0;
			span{
				margin-left: 10px;
			}
		}
	}
	.list-name{
		display: flex;
		justify-content: space-between;
		height: 40px;
		line-height: 40px;
		font-size: 13px;
		padding: 0 10px;
	}
	.demo-uni-row{
		font-size: 13px;
		height: 40px;
		line-height: 40px;
		padding: 0 10px;
	}
	
	.grid-item-box{
		width: 100px;
		height: 100px;
		margin: 0px 10px 0;
		padding-top: 30px;
		border: solid 1px #eee;
		background-color:  rgba(235, 228, 228,0.3);
		border-radius: 10px;
		box-shadow: 4px 4px 15px #eee;
		.text{
			display: block;
			text-align: center;
		}
	}
	.u-cell-text{
		font-size: 14px;
	}
	
	// 关联产品
	.productList-box{
		padding: 10px;
	}
	// 项目支出新增按钮
	.addBtn{
		width: 42px;
		min-height: 22px;
		line-height: 22px;
		background-color: #fd9540;
		color: #fff;
		font-size:12px;
		text-align: center;
		border-radius: 5px;

	}
	// 新增费用  按钮
	.pop-box{
		min-width: 300px;
		min-height: 200px;
		padding: 20px;
		position: relative;
		.title{
			padding-top: 5px;
			margin-right: 5px;
			
		}
		.button{
			width: 100px;
			display: flex;
			position: absolute;
			right: 40px;
			bottom: 20px;
			
		}
	}
	
</style>